<!-- /* Description for file.
 * 寻访状态定制
 * @copyright     Copyright 2008-2010, PHInfo Services Inc. (http://www.phinfoservices.com)
 * @package       ues
 * @subpackage    ues/app/views/resumeranks
 * @since         ues
 * @version       V0.0.1
 * @modifiedby    会兵2011年0729
 * @lastmodified  张海杰2011年0809
 */
 -->
<?php
echo $html->css ( 'tab' );
echo $html->css ( 'jquery-validate/css/screen' );
?>
<script type="text/javascript">
//Form验证
$(document).ready(function() {
	 $.validator.setDefaults({       
		 submitHandler: function(form) {    
		  form.submit();    
		}       
	});
});
</script>
<script>	
$(document).ready(function(){
	$("#VisitorstateToplist").change(function()
	{									
		var Toplist = $(this).find('option:selected').text();
		var color = $(this).find('option:selected').val();
		color = color.split("#");
		color = "#" + color[1];
		if($(this).val() < 0){
			$("#VisitorstateField1").attr("value",'');
			$("#VisitorstateField2").attr("value",'');
			$("#VisitorstateEditname").attr("value",'');
		}
		else{
			$("#VisitorstateField1").val(Toplist);
			$("#VisitorstateEditname").val(Toplist);
			$("#VisitorstateField2").val(color);
			$("#VisitorstateField2").attr("style","background-color:"+color);
		}
	});
});

$(document).ready(function(){

	$("#btnajaxDel").click(function(){
		if(!confirm("确定删除？"))
		return;
		var del=$("#VisitorstateEditname").val();
		$("#delStr").val(del);
		$("#VisitorstateDeleteForm").submit();
		});
	
	$("#btnajaxAdd").click(function(){
		var n=$("#VisitorstateField1").val();
		var c=$("#VisitorstateField2").val();
		$("#VisitorstateName").val(n);
		$("#VisitorstateColor").val(c);
		// validate signup form on keyup and submit
			$("#VisitorstateAddForm").validate({
				rules: {
				"data[Visitorstate][name]":{
						required: true,string: true,stringMinLength:0,stringMaxLength:30
					}
				},
				messages: {
					"data[Visitorstate][name]":{
					required:  "请输入寻访状态名称"
					}
				},
				//设置验证触发事件 
				focusInvalid: false, 
				onkeyup: false, 
				//设置错误信息提示DOM  
				errorPlacement: function(error, element) { 
				error.appendTo( element.parent()); 
				}
			});
			$("#VisitorstateAddForm").submit();
		});
	$("#btnajaxSave").click(function(){
		var n1=$("#VisitorstateField1").val();
		var c1=$("#VisitorstateField2").val();
		$("#name1").val(n1);
		$("#color1").val(c1);
		//alert(n1);
		// validate signup form on keyup and submit
			$("#VisitorstateEditForm").validate({
				rules: {
				"data[Visitorstate][name]":{
						required: true,string: true,stringMinLength:0,stringMaxLength:30
					}
				},
				messages: {
					"data[Visitorstate][name]":{
					required:  "请输入寻访状态名称"
					}
				},
				//设置验证触发事件 
				focusInvalid: false, 
				onkeyup: false, 
				//设置错误信息提示DOM  
				errorPlacement: function(error, element) { 
				error.appendTo( element.parent()); 
				}
			});
			$("#VisitorstateEditForm").submit();
		});
		$("#VisitorstateField2").click(function(){
			$("#divColor").toggle();
		});
});


function changevalue(color)
{
	var colorvalue = color.value;
	$("#VisitorstateField2").val(colorvalue);
	$("#VisitorstateField2").attr("style","background-color:"+colorvalue);
	$("#divColor").toggle();
}


</script>
<!-- 当前位置-->
<div id="tabmenubar">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td class="tabmenubartitle1"><?php echo  __('YourPosition');//您现在的位置：?></td>
		<td class="tabmenubartitle2"><?php echo __('Visitorrecord');//一级目录
										   echo '>';?>
									<?php echo $html->tag('span', __('Visitorstate',true));//当前操作地用span加粗?> 						  
		</td>
	</tr>
</table>
</div>
<!-- 当前位置-->
<div class="tabflex" style="width:30%">
<?php echo $form->create('Visitorstate',array('action'=>'add','type'=> 'post'));?>
<?php echo $form->hidden('name'); ?>
<?php echo $form->hidden('color'); ?>
<?php echo $form->end();?>

<?php echo $form->create('Visitorstate',array('action'=>'delete','type'=> 'post'));?>
<?php echo $form->hidden('name',array('id'=>'delStr'));?>
<?php echo $form->end();?>


<?php echo $form->create('Visitorstate',array('action'=>'edit','type'=> 'post'));?>
<?php echo $form->hidden('editname'); ?>
<?php echo $form->hidden('name',array('id'=>'name1')); ?>
<?php echo $form->hidden('color',array('id'=>'color1')); ?>

<!-- 寻访状态定制  -->
<fieldset><legend><?php __('Visitorstate');?></legend>
	<!-- 定制 -->

		<table width="95%" cellspacing="0" cellpadding="0" border="0" STYLE="text-align:left;">
			<tr>
				<td width="30px"></td>
				<td width="70px">名称</td>
				<td valign="top"><?php echo $form->text('Field1',array('class'=>'TextBoxE1')); ?></td>
				<td width="70px"><a><?php echo $html->image('add.gif', array('alt' =>  __('Add', true),'border'=>'0','id'=>'btnajaxAdd'));?> </a>
					 		<!-- 添加 --></td>

			</tr>
			<tr>
				<td></td>
				<td>颜色</td>
				<td valign="top"><input name="VisitorstateField2" class="TextBoxE1" type="text" readonly="readonly" id="VisitorstateField2"/></td>
				<td><a><?php echo $html->image('edit.gif', array('alt' =>  __('Edit', true),'border'=>'0','id'=>'btnajaxSave')); ?></a> 
				<!-- 修改 --></td>
			</tr>
			<tr>
				<td></td>
				<td colspan="3">
					<div id="divColor" style="display: none">
						<table id="dlColor" cellspacing="0" border="0" style="border-collapse:collapse;">
							<tr>
								<td><input type="button" value="#FF00FF" style="background-color:#FF00FF;height:20px;width:60px;border:0;CURSOR: hand" onclick="changevalue(this);" />
								</td>
								<td><input type="button" value="#FFCC66" style="background-color:#FFCC66;height:20px;width:60px;border:0;CURSOR: hand" onclick="changevalue(this);"/>
								</td>
								<td><input type="button" value="#0000FF" style="background-color:#0000FF;height:20px;width:60px;border:0;CURSOR: hand" onclick="changevalue(this);"/>
								</td>
								<td><input type="button" value="#3399CC" style="background-color:#3399CC;height:20px;width:60px;border:0;CURSOR: hand" onclick="changevalue(this);"/>
								</td>
							</tr>
							<tr>
								<td><input type="button" value="#FFCCFF" style="background-color:#FFCCFF;height:20px;width:60px;border:0;CURSOR: hand" onclick="changevalue(this);"/>
								</td>
								<td><input type="button" value="#99CCFF" style="background-color:#99CCFF;height:20px;width:60px;border:0;CURSOR: hand" onclick="changevalue(this);"/>
								</td>
								<td><input type="button" value="#99FFFF" style="background-color:#99FFFF;height:20px;width:60px;border:0;CURSOR: hand" onclick="changevalue(this);"/>
								</td>
							</tr>
						</table>
					</div>
				</td>
			</tr>
			<tr>
				<td></td>
				<td></td>	
				<td>
				<!-- 下拉列表 -->
				<?php
					$options = array();
					$colors = array();
					foreach($toplist as $eachrecord)
					{
						$i =0;$i++;
						$options[$eachrecord['Visitorstate']['id'].$eachrecord['Visitorstate']['color']] = $eachrecord['Visitorstate']['name'];
					}
					echo $form->input('toplist',array('options'=>$options,'label'=>false,'div'=>false,'class'=>'TextBoxE1','size'=>8));		
				?>
				</td>
				<td valign="top">
					<a><?php echo $html->image('delete.gif', array('alt' =>  __('Delete', true),'border'=>'0','id'=>'btnajaxDel'));?></a> 
							<!-- 删除 -->
				</td>
			</tr>
		</table>

</fieldset>

<!-- 寻访状态定制-->

<?php echo $form->end();?>
</div>